<template>
  <div>
    <van-swipe :autoplay="3000">
      <van-swipe-item v-for="(image, index) in images" :key="index">
        <img v-lazy="image.img" />
      </van-swipe-item>
    </van-swipe>

    <van-grid :border="false" :column-num="3">
      <van-grid-item to="/newslist">
        <img src="../assets/images/menu1.png" alt />
        <p>新闻资讯</p>
      </van-grid-item>
      <van-grid-item to="/photolist">
        <img src="../assets/images/menu2.png" alt />
        <p>图片分享</p>
      </van-grid-item>
      <van-grid-item to="/goodslist">
        <img src="../assets/images/menu3.png" alt />
        <p>商品购买</p>
      </van-grid-item>
      <van-grid-item to="/coupon">
        <img src="../assets/images/menu4.png" alt  />
        <p>优惠券</p>
      </van-grid-item>
      <van-grid-item to="/map">
        <img src="../assets/images/menu5.png" alt />
        <p>地图</p>
      </van-grid-item>
      <van-grid-item to="/validate">
        <img src="../assets/images/menu6.png" alt />
        <p>表单验证</p>
      </van-grid-item>
    </van-grid>
  </div>
</template>
<script>
export default {
  created() {
    this.getSwiper();
  },
  data() {
    return {
      images: []
    };
  },
  methods: {
    async getSwiper() {
      const { data: res } = await this.$http.get("/api/getlunbo");
      if (res.status != 0) return this.$toast.error("请求数据失败");
      this.images = res.message;
      console.log(this.images);
    }
  }
};
</script>
<style scoped lang="less">
.van-swipe {
  width: 100%;
  height: 200px;
  .van-swipe-item {
    width: 100%;
    text-align: center;
    img {
      width: 100%;
      height: 200px;
    }
  }
}
.van-grid-item{
  width:33.333333%;
  img{
    width:70px;
  }
}
</style>